package com.gm.commonlib.util.permission.domain;

import android.content.Context;
import android.text.TextUtils;


import com.gm.commonlib.util.permission.interfaces.IPermissionCallback;
import com.gm.commonlib.util.permission.ui.PermissionActivity;

import java.util.HashSet;

public class PermissionBuilder {

    private Context context;
    private HashSet<String> stringHashSet = new HashSet<>();

    public PermissionBuilder(Context context) {
        this.context = context;
    }

    public PermissionBuilder apply(String... permissionSet) {
        if (permissionSet != null) {
            for (String permission : permissionSet) {
                if (!TextUtils.isEmpty(permission)) {
                    stringHashSet.add(permission);
                }
            }
        }
        return this;
    }


    public void request(IPermissionCallback permissionCallback) {
     PermissionObject object = new PermissionObject();
        object.setPermissions(stringHashSet.toArray(new String[0]));
        PermissionActivity.apply(context, object, permissionCallback);
    }
}
